<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-01-20
 * Time: 16:24
 */

namespace app\admin\model;


use think\Model;

class HospitalModel extends Model
{
    // 确定链接表名
    protected $name = 'hospital';

    /**
     * 根据搜索条件获取用户列表信息
     * @param $where
     * @param $offset
     * @param $limit
     */
    public function gethospitalByWhere($where, $offset, $limit)
    {
        return $this->where($where)->limit($offset, $limit)->order('id desc')->select();
    }

    public function getAllHospital($where)
    {
        return $this->where($where)->count();
    }

    public function insertHospital($param)
    {
        try{

            $result =  $this->save($param);
            if(false === $result){
                // 验证失败 输出错误信息
                return msg(-1, '', $this->getError());
            }else{

                return msg(1, url('hospital/index'), '添加医院成功');
            }
        }catch(PDOException $e){

            return msg(-2, '', $e->getMessage());
        }
    }


}